package com.rotsel.mh3udb.app.Activities;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.rotsel.mh3udb.app.Adapters.PicTextListItemAdapter;
import com.rotsel.mh3udb.app.ListModels.PicTextItemModel;
import com.rotsel.mh3udb.app.R;
import com.rotsel.mh3udb.app.lists.*;
import com.rotsel.mh3udb.app.models.*;

public class WeaponTypeListActivity extends BaseActivity {
	private ListView weaponTypeList;
	
	@Override
	public void onCreate(Bundle savedInstanceState){
        Log.d("dev", "Creating weaponTypeList activity...");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list_view);

        ArrayList<WeaponTypeModel> allWeaponTypes = getDb().getAllWeaponTypes();
        PicTextListItemAdapter adapter = new PicTextListItemAdapter(this, allWeaponTypes);
		
		weaponTypeList = (ListView)findViewById(R.id.list);
		weaponTypeList.setAdapter(adapter);
		weaponTypeList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Log.d("dev", "Clicked Weapon Type item - position: " + position + " id: " + id);
                Log.d("dev", "Creating weapon type intent...");
                Intent intent = new Intent(WeaponTypeListActivity.this, WeaponListActivity.class);
                Bundle b = new Bundle();
                b.putInt("weaponTypeId", (int)id);
                intent.putExtras(b);
                Log.d("dev", "Weapon type intent created");
                startActivity(intent);
			}
		});
        Log.d("dev", "WeaponTypeList activity created");
    }

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
}
